package c.f.c.a.j;

import android.app.Activity;
import android.app.Fragment;
import c.f.c.a.b;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.List;
import java.util.WeakHashMap;

public final class d extends Fragment {
    public static final WeakHashMap<Activity, WeakReference<d>> b = new WeakHashMap();
    public final List<WeakReference<b<?>>> a = new ArrayList();

    /* JADX WARNING: Removed duplicated region for block: B:39:0x0091 A:{RETURN} */
    /* JADX WARNING: Removed duplicated region for block: B:30:0x007f  */
    /* JADX WARNING: Removed duplicated region for block: B:30:0x007f  */
    /* JADX WARNING: Removed duplicated region for block: B:39:0x0091 A:{RETURN} */
    /* JADX WARNING: Removed duplicated region for block: B:39:0x0091 A:{RETURN} */
    /* JADX WARNING: Removed duplicated region for block: B:30:0x007f  */
    /* JADX WARNING: Removed duplicated region for block: B:30:0x007f  */
    /* JADX WARNING: Removed duplicated region for block: B:39:0x0091 A:{RETURN} */
    public static void a(android.app.Activity r6, c.f.c.a.b r7) {
        /*
        r0 = "LifecycleCallbackFrg";
        r1 = "com.huawei.hmf.tasks.lifecycle_fragment_tag";
        r2 = b;
        r2 = r2.get(r6);
        r2 = (java.lang.ref.WeakReference) r2;
        if (r2 == 0) goto L_0x001b;
    L_0x000e:
        r3 = r2.get();
        if (r3 == 0) goto L_0x001b;
    L_0x0014:
        r6 = r2.get();
        r6 = (c.f.c.a.j.d) r6;
        goto L_0x007d;
    L_0x001b:
        r2 = r6.getFragmentManager();
        r3 = 0;
        r4 = r2.findFragmentByTag(r1);	 Catch:{ ClassCastException -> 0x0066 }
        r4 = (c.f.c.a.j.d) r4;	 Catch:{ ClassCastException -> 0x0066 }
        if (r4 != 0) goto L_0x0056;
    L_0x0028:
        r5 = new c.f.c.a.j.d;	 Catch:{ Exception -> 0x003d }
        r5.m1904init();	 Catch:{ Exception -> 0x003d }
        r2 = r2.beginTransaction();	 Catch:{ Exception -> 0x003a }
        r1 = r2.add(r5, r1);	 Catch:{ Exception -> 0x003a }
        r1.commitAllowingStateLoss();	 Catch:{ Exception -> 0x003a }
        r3 = r5;
        goto L_0x0057;
    L_0x003a:
        r1 = move-exception;
        r3 = r5;
        goto L_0x003e;
    L_0x003d:
        r1 = move-exception;
    L_0x003e:
        r2 = new java.lang.StringBuilder;	 Catch:{ ClassCastException -> 0x0054 }
        r5 = "create fragment failed.";
        r2.<init>(r5);	 Catch:{ ClassCastException -> 0x0054 }
        r1 = r1.getMessage();	 Catch:{ ClassCastException -> 0x0054 }
        r2.append(r1);	 Catch:{ ClassCastException -> 0x0054 }
        r1 = r2.toString();	 Catch:{ ClassCastException -> 0x0054 }
        android.util.Log.e(r0, r1);	 Catch:{ ClassCastException -> 0x0054 }
        goto L_0x0057;
    L_0x0054:
        r6 = move-exception;
        goto L_0x0064;
    L_0x0056:
        r3 = r4;
    L_0x0057:
        r1 = b;	 Catch:{ ClassCastException -> 0x0062 }
        r2 = new java.lang.ref.WeakReference;	 Catch:{ ClassCastException -> 0x0062 }
        r2.<init>(r3);	 Catch:{ ClassCastException -> 0x0062 }
        r1.put(r6, r2);	 Catch:{ ClassCastException -> 0x0062 }
        goto L_0x007c;
    L_0x0062:
        r6 = move-exception;
        r4 = r3;
    L_0x0064:
        r3 = r4;
        goto L_0x0067;
    L_0x0066:
        r6 = move-exception;
    L_0x0067:
        r1 = new java.lang.StringBuilder;
        r2 = "found LifecycleCallbackFragment but the type do not match. ";
        r1.<init>(r2);
        r6 = r6.getMessage();
        r1.append(r6);
        r6 = r1.toString();
        android.util.Log.e(r0, r6);
    L_0x007c:
        r6 = r3;
    L_0x007d:
        if (r6 == 0) goto L_0x0091;
    L_0x007f:
        r0 = r6.a;
        monitor-enter(r0);
        r6 = r6.a;	 Catch:{ all -> 0x008e }
        r1 = new java.lang.ref.WeakReference;	 Catch:{ all -> 0x008e }
        r1.<init>(r7);	 Catch:{ all -> 0x008e }
        r6.add(r1);	 Catch:{ all -> 0x008e }
        monitor-exit(r0);	 Catch:{ all -> 0x008e }
        return;
    L_0x008e:
        r6 = move-exception;
        monitor-exit(r0);	 Catch:{ all -> 0x008e }
        throw r6;
    L_0x0091:
        return;
        */
        throw new UnsupportedOperationException("Method not decompiled: c.f.c.a.j.d.a(android.app.Activity, c.f.c.a.b):void");
    }

    public final void onStop() {
        super.onStop();
        synchronized (this.a) {
            for (WeakReference weakReference : this.a) {
                b bVar = (b) weakReference.get();
                if (bVar != null) {
                    bVar.cancel();
                }
            }
            this.a.clear();
        }
    }
}
